package xin.marcher.module.common.enums.inventory;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * 分桶操作状态枚举
 */
public enum BucketOperateStatusEnum {

    /**
     * 未执行
     */
    UN_PROCESS(0, "0", "未执行"),
    /**
     * 正在执行
     */
    PROCESS(1, "1", "正在执行"),
    /**
     * 执行完成
     */
    FINISH(2, "2", "执行完成"),
    /**
     * 执行失败
     */
    FAIL(3, "3", "执行失败"),
    ;

    private Integer code;

    private String codeString;

    private String value;

    BucketOperateStatusEnum(Integer code, String codeString, String value) {
        this.code = code;
        this.codeString = codeString;
        this.value = value;
    }

    public Integer getCode() {
        return code;
    }

    public String getCodeString() {
        return codeString;
    }

    public String getValue() {
        return value;
    }

    public static Map<Integer, String> toMap() {
        Map<Integer, String> map = Maps.newHashMap();
        for (BucketOperateStatusEnum element : BucketOperateStatusEnum.values()) {
            map.put(element.getCode(), element.getValue());
        }
        return map;
    }

    public static BucketOperateStatusEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (BucketOperateStatusEnum element : BucketOperateStatusEnum.values()) {
            if (code.equals(element.getCode())) {
                return element;
            }
        }
        return null;
    }
}